#ifndef CDELEGATE_H
#define CDELEGATE_H

#include <QObject>
#include <QStyledItemDelegate>
#include <QWidget>
#include <QComboBox>
#include <QProgressBar>

class QWidget;
class QVariant;
class QPushButton;
class CModel;

class MulBtnWiget : public QWidget
{
    Q_OBJECT
public:
    explicit MulBtnWiget(const QModelIndex &index, QWidget *parent = nullptr);

    void setBtnData(const QVariant &data);

signals:
    void btnColor(const QString &color, const int &row);

private:
    QPushButton *_pButton1;
    QPushButton *_pButton2;
    QPushButton *_pButton3;
    QModelIndex _index;
};


class COpratorDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    enum ColType {
        STRING,
        COMBOBOX,
        PROGRESSBAR,
        MULBTN
    };

    explicit COpratorDelegate(QObject *parent = nullptr, const ColType &type=STRING);

    QWidget *createEditor(QWidget *parent,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const override;

    void setEditorData(QWidget *editor, const QModelIndex &index) const override;
    void setModelData(QWidget *editor,
                      QAbstractItemModel *model,
                      const QModelIndex &index) const override;

    void setCModel(CModel * const pModel) { _pModel = pModel; }

signals:
    void btnColor(const QString &color, const QModelIndex &index);

private:
    CModel *_pModel = nullptr;
    ColType _colType = STRING;
};

#endif // CDELEGATE_H
